The WHILE Statement
The WHILE statement in VectorScript will execute the same script section as long as the control expression, which returns a BOOLEAN value, evaluates to TRUE. The general syntax for the WHILE statement is:
WHILE <control expression> DO <statement>;
The control expression is evaluated prior to executing the controlled statement, and as such it can bypass the controlled statement altogether. For example:
 
 SetSelect(h);
In the example, a handle to the first object on the active layer is returned by the FActLayer() function call. If there are no objects on the active layer, the calls to select the object and obtain the next object on the layer are bypassed.
If there were objects on the layer, the example would automatically exit the loop when it ran out of objects to process. This is because the NextObj() call returns NIL when it cannot return a handle, and since the WHILE statement will evaluate the expression before executing its controlled statement, the example would bypass the controlled statement once the expression evaluated to FALSE (h = NIL). Unlike a FOR statement, the WHILE statement allows execution to be controlled from within the controlled statement.

Statements : Repetition Statements : The WHILE Statement

Nemetschek NA
Phone: 410.290.5114
Fax: 410.290.8050